<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    let arr = [2,0,0,4,12,0,34,8,23,64,12]
  // 用来存满足条件的元素
    let dayu = []
    // 遍历过程
    for (let i = 0; i < arr.length;i++){
    //   // 作比较 筛选出大于0的元素
    //   if(arr[i] > 0){
    //     dayu.push(arr[i])
    //   }
    // }
    dauy = arr[i] > 0? dayu.push(arr[i]): arr
    }
    alert(dayu)
    // console.log(dayu)

  </script>
</body>
</html>